﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>SetControlDelay - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The SetControlDelay function sets the delay that will occur after each control-modifying function." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>SetControlDelay</h1>

<p>Sets the delay that will occur after each control-modifying function.</p>

<pre class="Syntax"><span class="func">SetControlDelay</span> Delay</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>Delay</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
    <p>Time in milliseconds. Use -1 for no delay at all and 0 for the smallest possible delay. If unset, the default delay is 20.</p>
  </dd>

</dl>

<h2 id="Remarks">Remarks</h2>
<p>A short delay (sleep) is done automatically after every Control function that changes a control. This is done to improve the reliability of scripts because a control sometimes needs a period of "rest" after being changed by one of these functions. The rest period allows it to update itself and respond to the next function that the script may attempt to send to it.</p>
<p>Specifically, SetControlDelay affects the following 函数: <a href="ControlAddItem.htm">ControlAddItem</a>, <a href="ControlChoose.htm">ControlChoose</a>, <a href="ControlChooseString.htm">ControlChooseString</a>, <a href="ControlClick.htm">ControlClick</a>, <a href="ControlDeleteItem.htm">ControlDeleteItem</a>, <a href="ControlEditPaste.htm">ControlEditPaste</a>, <a href="ControlFindItem.htm">ControlFindItem</a>, <a href="ControlFocus.htm">ControlFocus</a>, <a href="ControlHide.htm">ControlHide</a>, <a href="ControlHideDropDown.htm">ControlHideDropDown</a>, <a href="ControlMove.htm">ControlMove</a>, <a href="ControlSetChecked.htm">ControlSetChecked</a>, <a href="ControlSetEnabled.htm">ControlSetEnabled</a>, <a href="ControlSetTab.htm">ControlSetTab</a>, <a href="ControlSetText.htm">ControlSetText</a>, <a href="ControlShow.htm">ControlShow</a>, <a href="ControlShowDropDown.htm">ControlShowDropDown</a>.</p>
<p><a href="ControlSend.htm">ControlSend</a> is not affected; it uses <a href="SetKeyDelay.htm">SetKeyDelay</a>.</p>
<p>Although a delay of -1 (no delay at all) is allowed, it is recommended that at least 0 be used, to increase confidence that the script will run correctly even when the CPU is under load.</p>
<p>A delay of 0 internally executes a Sleep(0), which yields the remainder of the script's timeslice to any other process that may need it. If there is none, Sleep(0) will not sleep at all.</p>
<p>If the CPU is slow or under load, or if window animation is enabled, higher delay values may be needed.</p>
<p>The built-in variable <strong>A_ControlDelay</strong> contains the current setting and can also be assigned a new value instead of calling SetControlDelay.</p>
<p>每个新运行的<a href="../misc/Threads.htm">线程</a>(如 <a href="../Hotkeys.htm">热键</a>, <a href="../objects/Menu.htm">自定义菜单项</a>或<a href="SetTimer.htm">定时</a>子程序) 都会以此函数的默认设置开始. 这个默认设置可以通过在脚本的自动执行段(脚本的顶部) 使用此函数来改变.</p>
<h2 id="Related">相关</h2>
<p><a href="Control.htm">Control functions</a>, <a href="SetWinDelay.htm">SetWinDelay</a>, <a href="SetKeyDelay.htm">SetKeyDelay</a>, <a href="SetMouseDelay.htm">SetMouseDelay</a></p>
<h2 id="Examples">示例</h2>
div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>SetControlDelay 0</pre>
</div>

</body>
</html>